using System.Collections.Generic;

namespace Kiwi.Container.Caching
{
    public class ComponentCache : IComponentCache
    {
        private readonly Dictionary<IComponentRegistration, object> _cache =
            new Dictionary<IComponentRegistration, object>(new ReferenceEqualityComparer<IComponentRegistration>());

        #region IComponentCache Members

        public bool TryGetComponent(IComponentRegistration key, out object component)
        {
            return _cache.TryGetValue(key, out component);
        }

        public void AddComponent(IComponentRegistration key, object component)
        {
            _cache.Add(key, component);
        }

        #endregion
    }
}